import axios from 'poros/http';

// const BASE_API = 'http://10.110.96.153:8030';
const BASE_API = '';

// 获取bp/rp 计划列表
export const postRPList = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/planProcess/pagePlan`,
    method: 'post',
    data,
  });

// 发起bp/rp 计划
export const postLunchPlan = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/planProcess/launchPlan`,
    method: 'post',
    data,
  });

// 查询模板
export const getTemplate = params =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/planProcess/queryTemplate`,
    method: 'get',
    params,
  });

// 保存模板
export const postSaveTemplate = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/template/batchInsert`,
    method: 'post',
    data,
  });

// 删除模板
export const deleteSaveTemplate = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/template/delete`,
    method: 'post',
    data,
  });

// 详情
export const getPlanDetail = params =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/planProcess/detail`,
    method: 'get',
    params,
  });

// 分组录入 提交
export const postPlanGroupRecord = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/planProcess/groupEntry`,
    method: 'post',
    data,
  });

//查询操作日志
export const getOperationLog = params =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/planProcess/queryLog/`,
    method: 'get',
    params,
  });

// 删除计划
export const postDeletePlan = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/planProcess/deletePlanById`,
    method: 'post',
    data,
  });

// 部长审批
export const postMinisterApprove = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/planProcess/ministerApprove`,
    method: 'post',
    data,
  });

// Kapm总监 审批
export const postKapmDirectorApprove = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/planProcess/kapmDirectorApprove`,
    method: 'post',
    data,
  });

// 销售总监 审批
export const postSaleDirectorApprove = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/planProcess/saleDirectorApprove`,
    method: 'post',
    data,
  });

// 提交终版确认
export const postFinalConfirmation = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/planProcess/finalConfirmation`,
    method: 'post',
    data,
  });

// 销售总监 确认
export const postSaleDirectorConfirm = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/planProcess/saleDirectorConfirm`,
    method: 'post',
    data,
  });

// Kapm总监 确认
export const postKapmDirectorConfirm = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/planProcess/kapmDirectorConfirm`,
    method: 'post',
    data,
  });

//model name列表查询接口
export const postModelNameList = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/modelName/listByPage`,
    method: 'post',
    data,
  });

//转他们处理列表接口
export const getOthersHandingList = params =>
  axios({
    url: `${BASE_API}/api/poros-permission/secStaff/list`,
    method: 'get',
    params,
  });

// 复用录入明细
export const postReuseDetailList = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/planProcess/reuse`,
    method: 'post',
    data,
  });

// 导出明细模板
export const postExportDetailTemplate = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/planDetail/downExcelImportTemplate`,
    method: 'post',
    responseType: 'arraybuffer',
    hasInterceptors: true,
    data,
  });

// 导出明细
export const postExportDetail = (data, type) =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/planDetail/exportExcel/${type}`,
    method: 'post',
    responseType: 'arraybuffer',
    hasInterceptors: true,
    data,
  });

// 导入明细数据
export const postUploadFile = (file, planId) => {
  const formData = new FormData();
  formData.append('file', file);
  return axios({
    url: `${BASE_API}/api/salesforecast-service/planDetail/importExcel/${planId}`,
    headers: { 'Content-Type': 'nultipart/form-data' },
    method: 'post',
    data: formData,
  });
};
// new Promise(resolve => {
//   setTimeout(() => {
//     resolve({ data });
//   }, 1000);
// });

// 转他人处理接口
export const postReuseDetail = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/planProcess/forward`,
    method: 'post',
    data,
  });

// 获取BP关系列表
export const getBpRelationList = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/planDetail/listByPage`,
    method: 'post',
    data,
  });
